@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
               
                
                <label>
                    分类：<br>
                    <select name="type">
                        <option value="">全部</option>
                        @foreach($cat as $k=>$v)
                        <option value="{{$k}}" @if($k==$_search['type'] && $_search['type']!='') selected="selected" @endif >{{$v}}</option>
                        @endforeach
                    </select>
                </label>
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            <table class="table">
                <caption>文章列表</caption>
                <thead>
                    <tr>
                        <th>#</th>
                        <th>分类</th>
                        <th>图片</th>
                        <th>内容</th>
                        <th>分享次数</th>
                        <th>状态</th>
                        <th>日期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr>
                            <td>{{$item->id}}</td>
                            <td>{{$cat[$item->type]}}</td>
                            <td>
                                @foreach($item->pic as $img)
                                <img src="{{$img}}" style="max-width: 200px;">
                                @endforeach
                            </td>
                            <td>{{$item->content}}</td>
                            <td>{{$item->share_number}}</td>
                            <td>{{$item->status==1?'显示':'下线'}}</td>
                            <td>{{date('Y/m/d H:i:s',$item->time)}}</td>
                            <td><a href="/Share/edit/{{ $item->id }}">编辑</a></td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}

function baidu(id,obj){
    $.post("/theme/ajax_post_baidu/"+id,{table:'theme'},function(json){
            if(json.status==1){
                $("#baidu_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
}
</script>
@endsection